﻿// Copyright 2009 Mike Geise
// 
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
// 
//     http://www.apache.org/licenses/LICENSE-2.0
// 
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

namespace Falcon.Core.Domain
{
	using Falcon.Core.Validation;

	public class UserProfile : EntityBase<UserProfile>
	{
		private UserAvatar _avatar;

		/// <summary>
		/// Initializes a new instance of the <see cref="UserProfile"/> class.
		/// </summary>
		public UserProfile()
		{
			DeterminePermission(Roles.Users);
		}

		/// <summary>
		/// Gets or sets the avatar id.
		/// </summary>
		/// <value>The avatar id.</value>
		public virtual int AvatarId
		{
			get;
			set;
		}

		/// <summary>
		/// Gets or sets the title.
		/// </summary>
		/// <value>The title.</value>
		public virtual string Title
		{
			get;
			set;
		}

		/// <summary>
		/// Gets or sets the homepage.
		/// </summary>
		/// <value>The homepage.</value>
		public virtual string Homepage
		{
			get;
			set;
		}

		/// <summary>
		/// Gets or sets the icq.
		/// </summary>
		/// <value>The icq.</value>
		public virtual string Icq
		{
			get;
			set;
		}

		/// <summary>
		/// Gets or sets the aim.
		/// </summary>
		/// <value>The aim.</value>
		public virtual string Aim
		{
			get;
			set;
		}

		/// <summary>
		/// Gets or sets the MSN.
		/// </summary>
		/// <value>The MSN.</value>
		public virtual string Msn
		{
			get;
			set;
		}

		/// <summary>
		/// Gets or sets the yahoo.
		/// </summary>
		/// <value>The yahoo.</value>
		public virtual string Yahoo
		{
			get;
			set;
		}

		/// <summary>
		/// Gets or sets the jabber.
		/// </summary>
		/// <value>The jabber.</value>
		public virtual string Jabber
		{
			get;
			set;
		}

		/// <summary>
		/// Gets or sets the skype.
		/// </summary>
		/// <value>The skype.</value>
		public virtual string Skype
		{
			get;
			set;
		}

		/// <summary>
		/// Gets or sets the signature.
		/// </summary>
		/// <value>The signature.</value>
		public virtual string Signature
		{
			get;
			set;
		}

		/// <summary>
		/// Gets or sets the signature parsed.
		/// </summary>
		/// <value>The signature parsed.</value>
		public virtual string SignatureParsed
		{
			get;
			set;
		}

		/// <summary>
		/// Gets or sets the avatar.
		/// </summary>
		/// <value>The avatar.</value>
		public virtual UserAvatar Avatar
		{
			get
			{
				return _avatar;
			}
			set
			{
				_avatar = value;

				if (_avatar != null)
				{
					this.AvatarId = _avatar.Id;
				}
			}
		}

		/// <summary>
		/// Validation rules for this instance.
		/// </summary>
		/// <returns></returns>
		public override Validator<UserProfile> Rules()
		{
			return base.Rules();
		}

		/// <summary>
		/// Validates this instance.
		/// </summary>
		public override void Validate()
		{
			this.Rules().Validate(this);
		}
	}
}